using System;
using System.Data;
using System.Xml;
using System.Runtime.Serialization;
using System.Collections;
using System.Collections.Generic;
using Widgetsphere.Core.Logging;
using Widgetsphere.Core.Exceptions;
using Widgetsphere.Core.DataAccess;
using ACME.Northwind.Business;
using ACME.Northwind.Business.Rules;
using Widgetsphere.Core.WinUI;
using ACME.Northwind.Domain.Objects;
using System.ComponentModel;
using Widgetsphere.Core.EventArgs;
using ACME.Northwind.Business.Objects.Composites;
using System.IO;

namespace ACME.Northwind.Business.Objects
{
	/// <summary>
	/// Interface definition for the 'Order' entity
	/// </summary>
	public interface IOrder : IPersistableBusinessObject, IAuditable, ICloneable
	{
		#region Properties

		/// <summary>
		/// The CustomerId field
		/// </summary>
		string CustomerId { get; set; }
		/// <summary>
		/// The EmployeeId field
		/// </summary>
		int? EmployeeId { get; set; }
		/// <summary>
		/// The Freight field
		/// </summary>
		decimal? Freight { get; set; }
		/// <summary>
		/// The OrderDate field
		/// </summary>
		DateTime? OrderDate { get; set; }
		/// <summary>
		/// The OrderId field
		/// </summary>
		int OrderId { get; }
		/// <summary>
		/// The RequiredDate field
		/// </summary>
		DateTime? RequiredDate { get; set; }
		/// <summary>
		/// The ShipAddress field
		/// </summary>
		string ShipAddress { get; set; }
		/// <summary>
		/// The ShipCity field
		/// </summary>
		string ShipCity { get; set; }
		/// <summary>
		/// The ShipCountry field
		/// </summary>
		string ShipCountry { get; set; }
		/// <summary>
		/// The ShipName field
		/// </summary>
		string ShipName { get; set; }
		/// <summary>
		/// The ShippedDate field
		/// </summary>
		DateTime? ShippedDate { get; set; }
		/// <summary>
		/// The ShipPostalCode field
		/// </summary>
		string ShipPostalCode { get; set; }
		/// <summary>
		/// The ShipRegion field
		/// </summary>
		string ShipRegion { get; set; }
		/// <summary>
		/// The ShipVia field
		/// </summary>
		int? ShipVia { get; set; }

		#endregion

		#region Methods

		/// <summary>
		/// This event is called before persisting to the database.
		/// </summary>
		event EventHandler<BusinessObjectEventArgs> Validate;

		/// <summary>
		/// Removes this object from its parent collection. It will not be deleted from the database.
		/// </summary>
		void Remove();

		/// <summary>
		/// The primary key for this object
		/// </summary>
		new OrderPrimaryKey PrimaryKey { get; }

		/// <summary>
		/// Persists this object to the database.
		/// </summary>
		new void Persist();

		/// <summary>
		/// Creates a clone of this object.
		/// </summary>
		new IBusinessObject Clone();

		#endregion

	}

	/// <summary>
	/// Class definition for the 'Order' entity
	/// </summary>
	[Serializable()]
	public partial class Order : BusinessObjectPersistableBase, IPersistableBusinessObject, IOrder
	{
		#region Class Members

		#region FieldNameConstants Enumeration

		/// <summary>
		/// Enumeration to define each property that maps to a database field for the 'Order' table.
		/// </summary>
		public enum FieldNameConstants
		{
			 /// <summary>
			 /// Field mapping for the 'ShipVia' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipVia' property")]
			ShipVia,
			 /// <summary>
			 /// Field mapping for the 'ShipRegion' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipRegion' property")]
			ShipRegion,
			 /// <summary>
			 /// Field mapping for the 'ShipPostalCode' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipPostalCode' property")]
			ShipPostalCode,
			 /// <summary>
			 /// Field mapping for the 'ShippedDate' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShippedDate' property")]
			ShippedDate,
			 /// <summary>
			 /// Field mapping for the 'ShipName' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipName' property")]
			ShipName,
			 /// <summary>
			 /// Field mapping for the 'ShipCountry' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipCountry' property")]
			ShipCountry,
			 /// <summary>
			 /// Field mapping for the 'ShipCity' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipCity' property")]
			ShipCity,
			 /// <summary>
			 /// Field mapping for the 'ShipAddress' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ShipAddress' property")]
			ShipAddress,
			 /// <summary>
			 /// Field mapping for the 'RequiredDate' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'RequiredDate' property")]
			RequiredDate,
			 /// <summary>
			 /// Field mapping for the 'OrderId' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'OrderId' property")]
			OrderId,
			 /// <summary>
			 /// Field mapping for the 'OrderDate' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'OrderDate' property")]
			OrderDate,
			 /// <summary>
			 /// Field mapping for the 'Freight' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'Freight' property")]
			Freight,
			 /// <summary>
			 /// Field mapping for the 'EmployeeId' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'EmployeeId' property")]
			EmployeeId,
			 /// <summary>
			 /// Field mapping for the 'CustomerId' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'CustomerId' property")]
			CustomerId,
			 /// <summary>
			 /// Field mapping for the 'CreatedBy' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'CreatedBy' property")]
			CreatedBy,
			 /// <summary>
			 /// Field mapping for the 'CreatedDate' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'CreatedDate' property")]
			CreatedDate,
			 /// <summary>
			 /// Field mapping for the 'ModifiedBy' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ModifiedBy' property")]
			ModifiedBy,
			 /// <summary>
			 /// Field mapping for the 'ModifiedDate' property
			 /// </summary>
			[System.ComponentModel.Description("Field mapping for the 'ModifiedDate' property")]
			ModifiedDate,
		}
		#endregion

		internal DomainOrder wrappedClass;

		#endregion

		#region Constructors

		/// <summary>
		/// Creates a 'Order' object from a domain object
		/// </summary>
		internal Order(DomainOrder classToWrap)
		{
			wrappedClass = classToWrap;
		}

		/// <summary>
		/// Creates a 'Order' object from a DataRowView
		/// </summary>
		internal Order(DataRowView drvToWrap)
		{
			wrappedClass = (DomainOrder)drvToWrap.Row;
		}

		#endregion

		#region Events

		/// <summary>
		/// This event is raised before the 'CustomerId' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> CustomerIdChanging;

		/// <summary>
		/// This event is raised when the 'CustomerId' field is changed.
		/// </summary>
		public event EventHandler CustomerIdChanged;

		/// <summary>
		/// This event is raised before the 'EmployeeId' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<int?>> EmployeeIdChanging;

		/// <summary>
		/// This event is raised when the 'EmployeeId' field is changed.
		/// </summary>
		public event EventHandler EmployeeIdChanged;

		/// <summary>
		/// This event is raised before the 'Freight' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<decimal?>> FreightChanging;

		/// <summary>
		/// This event is raised when the 'Freight' field is changed.
		/// </summary>
		public event EventHandler FreightChanged;

		/// <summary>
		/// This event is raised before the 'OrderDate' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<DateTime?>> OrderDateChanging;

		/// <summary>
		/// This event is raised when the 'OrderDate' field is changed.
		/// </summary>
		public event EventHandler OrderDateChanged;

		/// <summary>
		/// This event is raised before the 'OrderId' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<int>> OrderIdChanging;

		/// <summary>
		/// This event is raised when the 'OrderId' field is changed.
		/// </summary>
		public event EventHandler OrderIdChanged;

		/// <summary>
		/// This event is raised before the 'RequiredDate' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<DateTime?>> RequiredDateChanging;

		/// <summary>
		/// This event is raised when the 'RequiredDate' field is changed.
		/// </summary>
		public event EventHandler RequiredDateChanged;

		/// <summary>
		/// This event is raised before the 'ShipAddress' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipAddressChanging;

		/// <summary>
		/// This event is raised when the 'ShipAddress' field is changed.
		/// </summary>
		public event EventHandler ShipAddressChanged;

		/// <summary>
		/// This event is raised before the 'ShipCity' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipCityChanging;

		/// <summary>
		/// This event is raised when the 'ShipCity' field is changed.
		/// </summary>
		public event EventHandler ShipCityChanged;

		/// <summary>
		/// This event is raised before the 'ShipCountry' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipCountryChanging;

		/// <summary>
		/// This event is raised when the 'ShipCountry' field is changed.
		/// </summary>
		public event EventHandler ShipCountryChanged;

		/// <summary>
		/// This event is raised before the 'ShipName' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipNameChanging;

		/// <summary>
		/// This event is raised when the 'ShipName' field is changed.
		/// </summary>
		public event EventHandler ShipNameChanged;

		/// <summary>
		/// This event is raised before the 'ShippedDate' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<DateTime?>> ShippedDateChanging;

		/// <summary>
		/// This event is raised when the 'ShippedDate' field is changed.
		/// </summary>
		public event EventHandler ShippedDateChanged;

		/// <summary>
		/// This event is raised before the 'ShipPostalCode' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipPostalCodeChanging;

		/// <summary>
		/// This event is raised when the 'ShipPostalCode' field is changed.
		/// </summary>
		public event EventHandler ShipPostalCodeChanged;

		/// <summary>
		/// This event is raised before the 'ShipRegion' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<string>> ShipRegionChanging;

		/// <summary>
		/// This event is raised when the 'ShipRegion' field is changed.
		/// </summary>
		public event EventHandler ShipRegionChanged;

		/// <summary>
		/// This event is raised before the 'ShipVia' field is changed providing a chance to cancel the action.
		/// </summary>
		public event EventHandler<BusinessObjectCancelEventArgs<int?>> ShipViaChanging;

		/// <summary>
		/// This event is raised when the 'ShipVia' field is changed.
		/// </summary>
		public event EventHandler ShipViaChanged;

		/// <summary>
		/// Raises the CustomerIdChanging event.
		/// </summary>
		protected virtual void OnCustomerIdChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.CustomerIdChanging != null)
				this.CustomerIdChanging(this, e);
		}

		/// <summary>
		/// Raises the CustomerIdChanged event.
		/// </summary>
		protected virtual void OnCustomerIdChanged(System.EventArgs e)
		{
			if (this.CustomerIdChanged != null)
				this.CustomerIdChanged(this, e);
		}

		/// <summary>
		/// Raises the EmployeeIdChanging event.
		/// </summary>
		protected virtual void OnEmployeeIdChanging(BusinessObjectCancelEventArgs<int?> e)
		{
			if (this.EmployeeIdChanging != null)
				this.EmployeeIdChanging(this, e);
		}

		/// <summary>
		/// Raises the EmployeeIdChanged event.
		/// </summary>
		protected virtual void OnEmployeeIdChanged(System.EventArgs e)
		{
			if (this.EmployeeIdChanged != null)
				this.EmployeeIdChanged(this, e);
		}

		/// <summary>
		/// Raises the FreightChanging event.
		/// </summary>
		protected virtual void OnFreightChanging(BusinessObjectCancelEventArgs<decimal?> e)
		{
			if (this.FreightChanging != null)
				this.FreightChanging(this, e);
		}

		/// <summary>
		/// Raises the FreightChanged event.
		/// </summary>
		protected virtual void OnFreightChanged(System.EventArgs e)
		{
			if (this.FreightChanged != null)
				this.FreightChanged(this, e);
		}

		/// <summary>
		/// Raises the OrderDateChanging event.
		/// </summary>
		protected virtual void OnOrderDateChanging(BusinessObjectCancelEventArgs<DateTime?> e)
		{
			if (this.OrderDateChanging != null)
				this.OrderDateChanging(this, e);
		}

		/// <summary>
		/// Raises the OrderDateChanged event.
		/// </summary>
		protected virtual void OnOrderDateChanged(System.EventArgs e)
		{
			if (this.OrderDateChanged != null)
				this.OrderDateChanged(this, e);
		}

		/// <summary>
		/// Raises the OrderIdChanging event.
		/// </summary>
		protected virtual void OnOrderIdChanging(BusinessObjectCancelEventArgs<int> e)
		{
			if (this.OrderIdChanging != null)
				this.OrderIdChanging(this, e);
		}

		/// <summary>
		/// Raises the OrderIdChanged event.
		/// </summary>
		protected virtual void OnOrderIdChanged(System.EventArgs e)
		{
			if (this.OrderIdChanged != null)
				this.OrderIdChanged(this, e);
		}

		/// <summary>
		/// Raises the RequiredDateChanging event.
		/// </summary>
		protected virtual void OnRequiredDateChanging(BusinessObjectCancelEventArgs<DateTime?> e)
		{
			if (this.RequiredDateChanging != null)
				this.RequiredDateChanging(this, e);
		}

		/// <summary>
		/// Raises the RequiredDateChanged event.
		/// </summary>
		protected virtual void OnRequiredDateChanged(System.EventArgs e)
		{
			if (this.RequiredDateChanged != null)
				this.RequiredDateChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipAddressChanging event.
		/// </summary>
		protected virtual void OnShipAddressChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipAddressChanging != null)
				this.ShipAddressChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipAddressChanged event.
		/// </summary>
		protected virtual void OnShipAddressChanged(System.EventArgs e)
		{
			if (this.ShipAddressChanged != null)
				this.ShipAddressChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipCityChanging event.
		/// </summary>
		protected virtual void OnShipCityChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipCityChanging != null)
				this.ShipCityChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipCityChanged event.
		/// </summary>
		protected virtual void OnShipCityChanged(System.EventArgs e)
		{
			if (this.ShipCityChanged != null)
				this.ShipCityChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipCountryChanging event.
		/// </summary>
		protected virtual void OnShipCountryChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipCountryChanging != null)
				this.ShipCountryChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipCountryChanged event.
		/// </summary>
		protected virtual void OnShipCountryChanged(System.EventArgs e)
		{
			if (this.ShipCountryChanged != null)
				this.ShipCountryChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipNameChanging event.
		/// </summary>
		protected virtual void OnShipNameChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipNameChanging != null)
				this.ShipNameChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipNameChanged event.
		/// </summary>
		protected virtual void OnShipNameChanged(System.EventArgs e)
		{
			if (this.ShipNameChanged != null)
				this.ShipNameChanged(this, e);
		}

		/// <summary>
		/// Raises the ShippedDateChanging event.
		/// </summary>
		protected virtual void OnShippedDateChanging(BusinessObjectCancelEventArgs<DateTime?> e)
		{
			if (this.ShippedDateChanging != null)
				this.ShippedDateChanging(this, e);
		}

		/// <summary>
		/// Raises the ShippedDateChanged event.
		/// </summary>
		protected virtual void OnShippedDateChanged(System.EventArgs e)
		{
			if (this.ShippedDateChanged != null)
				this.ShippedDateChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipPostalCodeChanging event.
		/// </summary>
		protected virtual void OnShipPostalCodeChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipPostalCodeChanging != null)
				this.ShipPostalCodeChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipPostalCodeChanged event.
		/// </summary>
		protected virtual void OnShipPostalCodeChanged(System.EventArgs e)
		{
			if (this.ShipPostalCodeChanged != null)
				this.ShipPostalCodeChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipRegionChanging event.
		/// </summary>
		protected virtual void OnShipRegionChanging(BusinessObjectCancelEventArgs<string> e)
		{
			if (this.ShipRegionChanging != null)
				this.ShipRegionChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipRegionChanged event.
		/// </summary>
		protected virtual void OnShipRegionChanged(System.EventArgs e)
		{
			if (this.ShipRegionChanged != null)
				this.ShipRegionChanged(this, e);
		}

		/// <summary>
		/// Raises the ShipViaChanging event.
		/// </summary>
		protected virtual void OnShipViaChanging(BusinessObjectCancelEventArgs<int?> e)
		{
			if (this.ShipViaChanging != null)
				this.ShipViaChanging(this, e);
		}

		/// <summary>
		/// Raises the ShipViaChanged event.
		/// </summary>
		protected virtual void OnShipViaChanged(System.EventArgs e)
		{
			if (this.ShipViaChanged != null)
				this.ShipViaChanged(this, e);
		}

		#endregion

		#region Properties

		/// <summary>
		/// The current state of this object.
		/// </summary>
		public Widgetsphere.Core.DataAccess.SubDomainBase.ItemStateConstants ItemState
		{
			get { return (Widgetsphere.Core.DataAccess.SubDomainBase.ItemStateConstants)int.Parse(wrappedClass.RowState.ToString("d")); }
		}

		/// <summary>
		/// Determines the type of collection that contains this object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public Collections Container
		{
			get { return Collections.OrderCollection; }
		}

		#region CreatedBy / ModifiedBy Section

		/// <summary>
		/// The audit field for the 'Modified By' column.
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		public virtual string ModifiedBy
		{
			get
			{
				object o = this.wrappedClass[this.wrappedClass.ParentCol.ModifiedByColumn];
				if (o == DBNull.Value) return null;
				else return (string)o;
			}
			internal set { this.wrappedClass[this.wrappedClass.ParentCol.ModifiedByColumn] = value; }
		}

		/// <summary>
		/// The audit field for the 'Modified Date' column.
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		public virtual DateTime? ModifiedDate
		{
			get
			{
				object o = this.wrappedClass[this.wrappedClass.ParentCol.ModifiedDateColumn];
				if (o == DBNull.Value) return null;
				else return (DateTime)o;
			}
			internal set { this.wrappedClass[this.wrappedClass.ParentCol.ModifiedDateColumn] = value; }
		}

		/// <summary>
		/// Sets 'ModifiedBy' column.
		/// </summary>
		public virtual void SetModifiedDate(DateTime newValue)
		{
			this.wrappedClass[this.wrappedClass.ParentCol.ModifiedDateColumn] = newValue;
		}

		/// <summary>
		/// The audit field for the 'Created By' column.
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		public virtual string CreatedBy
		{
			get
			{
				object o = this.wrappedClass[this.wrappedClass.ParentCol.CreatedByColumn];
				if (o == DBNull.Value) return null;
				else return (string)o;
			}
			internal set { this.wrappedClass[this.wrappedClass.ParentCol.CreatedByColumn] = value; }
		}

		/// <summary>
		/// The audit field for the 'Created Date' column.
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		public virtual DateTime? CreatedDate
		{
			get
			{
				object o = this.wrappedClass[this.wrappedClass.ParentCol.CreatedDateColumn];
				if (o == DBNull.Value) return null;
				else return (DateTime)o;
			}
			internal set { this.wrappedClass[this.wrappedClass.ParentCol.CreatedDateColumn] = value; }
		}

		/// <summary>
		/// Sets 'ModifiedBy' column.
		/// </summary>
		public virtual void SetCreatedDate(DateTime newValue)
		{
			this.wrappedClass[this.wrappedClass.ParentCol.CreatedDateColumn] = newValue;
		}

		[System.ComponentModel.Browsable(false)]
		internal virtual byte[] TimeStamp
		{
			get
			{
				 object o = this.wrappedClass[this.wrappedClass.ParentCol.TimeStampColumn];
				 return (byte[])o;
			}
			set { this.wrappedClass[this.wrappedClass.ParentCol.TimeStampColumn] = value; }
		}

		#endregion

		/// <summary>
		/// Determines if this object is part of a collection or is detached
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual bool IsParented
		{
		  get { return (((DataRow)this.WrappedClass).RowState != DataRowState.Detached); }
		}

		/// <summary>
		/// Returns the internal object that this object wraps
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		internal virtual object WrappedClass
		{
			get{ return wrappedClass; }
			set{ wrappedClass = (DomainOrder)value; }
		}

		//WrappingClass Interface
		object IWrappingClass.WrappedClass
		{
			get { return this.WrappedClass; }
			set { this.WrappedClass = value; }
		}

		/// <summary>
		/// The primary key for this object
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual OrderPrimaryKey PrimaryKey
		{
			get
			{
				try
				{
					return wrappedClass.PrimaryKey;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}

		/// <summary>
		/// Property for table field: CustomerID
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string CustomerId
		{
			get
			{
				try { return wrappedClass.CustomerId; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.CustomerId))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.CustomerId", GetMaxLength(FieldNameConstants.CustomerId)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnCustomerIdChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.CustomerId = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("CustomerId"));
						this.OnCustomerIdChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: EmployeeID
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual int? EmployeeId
		{
			get
			{
				try { return wrappedClass.EmployeeId; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{

					BusinessObjectCancelEventArgs<int?> cancelArgs = new BusinessObjectCancelEventArgs<int?>(value);
					this.OnEmployeeIdChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.EmployeeId = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("EmployeeId"));
						this.OnEmployeeIdChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: Freight
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual decimal? Freight
		{
			get
			{
				try { return wrappedClass.Freight; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					BusinessObjectCancelEventArgs<decimal?> cancelArgs = new BusinessObjectCancelEventArgs<decimal?>(value);
					this.OnFreightChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.Freight = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("Freight"));
						this.OnFreightChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: OrderDate
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual DateTime? OrderDate
		{
			get
			{
				try { return wrappedClass.OrderDate; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					BusinessObjectCancelEventArgs<DateTime?> cancelArgs = new BusinessObjectCancelEventArgs<DateTime?>(value);
					this.OnOrderDateChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.OrderDate = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("OrderDate"));
						this.OnOrderDateChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: OrderID
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual int OrderId
		{
			get
			{
				try { return wrappedClass.OrderId; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}

		/// <summary>
		/// Property for table field: RequiredDate
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual DateTime? RequiredDate
		{
			get
			{
				try { return wrappedClass.RequiredDate; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					BusinessObjectCancelEventArgs<DateTime?> cancelArgs = new BusinessObjectCancelEventArgs<DateTime?>(value);
					this.OnRequiredDateChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.RequiredDate = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("RequiredDate"));
						this.OnRequiredDateChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipAddress
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipAddress
		{
			get
			{
				try { return wrappedClass.ShipAddress; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipAddress))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipAddress", GetMaxLength(FieldNameConstants.ShipAddress)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipAddressChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipAddress = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipAddress"));
						this.OnShipAddressChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipCity
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipCity
		{
			get
			{
				try { return wrappedClass.ShipCity; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipCity))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipCity", GetMaxLength(FieldNameConstants.ShipCity)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipCityChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipCity = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipCity"));
						this.OnShipCityChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipCountry
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipCountry
		{
			get
			{
				try { return wrappedClass.ShipCountry; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipCountry))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipCountry", GetMaxLength(FieldNameConstants.ShipCountry)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipCountryChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipCountry = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipCountry"));
						this.OnShipCountryChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipName
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipName
		{
			get
			{
				try { return wrappedClass.ShipName; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipName))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipName", GetMaxLength(FieldNameConstants.ShipName)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipNameChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipName = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipName"));
						this.OnShipNameChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShippedDate
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual DateTime? ShippedDate
		{
			get
			{
				try { return wrappedClass.ShippedDate; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					BusinessObjectCancelEventArgs<DateTime?> cancelArgs = new BusinessObjectCancelEventArgs<DateTime?>(value);
					this.OnShippedDateChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShippedDate = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShippedDate"));
						this.OnShippedDateChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipPostalCode
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipPostalCode
		{
			get
			{
				try { return wrappedClass.ShipPostalCode; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipPostalCode))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipPostalCode", GetMaxLength(FieldNameConstants.ShipPostalCode)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipPostalCodeChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipPostalCode = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipPostalCode"));
						this.OnShipPostalCodeChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipRegion
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual string ShipRegion
		{
			get
			{
				try { return wrappedClass.ShipRegion; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				if ((value != null) && (value.Length > GetMaxLength(FieldNameConstants.ShipRegion))) throw new Exception(string.Format(GlobalValues.ERROR_DATA_TOO_BIG, value, "Order.ShipRegion", GetMaxLength(FieldNameConstants.ShipRegion)));
				try
				{
					BusinessObjectCancelEventArgs<string> cancelArgs = new BusinessObjectCancelEventArgs<string>(value);
					this.OnShipRegionChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipRegion = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipRegion"));
						this.OnShipRegionChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		/// <summary>
		/// Property for table field: ShipVia
		/// </summary>
		[System.ComponentModel.Browsable(true)]
		[System.ComponentModel.Description("")]
		[Widgetsphere.Core.Attributes.DataSetting("", false, 0)]
		public virtual int? ShipVia
		{
			get
			{
				try { return wrappedClass.ShipVia; }
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{

					BusinessObjectCancelEventArgs<int?> cancelArgs = new BusinessObjectCancelEventArgs<int?>(value);
					this.OnShipViaChanging(cancelArgs);
					if (!cancelArgs.Cancel)
					{
						lock (this)
						{
							wrappedClass.ShipVia = cancelArgs.NewValue;
						}
						this.ModifiedDate = DateTime.Now;
						this.OnPropertyChanged(new PropertyChangedEventArgs("ShipVia"));
						this.OnShipViaChanged(new EventArgs());
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}

		}

		internal virtual void ReleaseNonIdentifyingRelationships()
		{
			try
			{
				wrappedClass.ReleaseNonIdentifyingRelationships();
			}
			catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
			catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
			catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
		}

		/// <summary>
		/// A list of related 'OrderDetail' items
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual BusinessObjectList<OrderDetail> OrderDetailList
		{
			get
			{
				try
				{
					if (this.ParentCollection == null)
					{
						lock (this)
						{
							return wrappedClass.OrderDetailList;
						}
					}
					else
					{
						lock (this.ParentCollection.SubDomain)
						{
							return wrappedClass.OrderDetailList;
						}
					}
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}

		/// <summary>
		/// Gets or sets the related 'Customer' object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual Customer CustomerItem
		{
			get
			{
				try
				{
					if (wrappedClass.CustomerItem != null) return new Customer(wrappedClass.CustomerItem);
					else return null;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					wrappedClass.CustomerItem = value.wrappedClass;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}
		/// <summary>
		/// Gets or sets the related 'Employee' object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual Employee EmployeeItem
		{
			get
			{
				try
				{
					if (wrappedClass.EmployeeItem != null) return new Employee(wrappedClass.EmployeeItem);
					else return null;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					wrappedClass.EmployeeItem = value.wrappedClass;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}
		/// <summary>
		/// Gets or sets the related 'Shipper' object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public virtual Shipper ShipperItem
		{
			get
			{
				try
				{
					if (wrappedClass.ShipperItem != null) return new Shipper(wrappedClass.ShipperItem);
					else return null;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
			set
			{
				try
				{
					wrappedClass.ShipperItem = value.wrappedClass;
				}
				catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
				catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
				catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
			}
		}

		#endregion

		#region Collection Operation Methods

		/// <summary>
		/// This event is called before persisting to the database.
		/// </summary>
		public event EventHandler<BusinessObjectEventArgs> Validate;

		/// <summary>
		/// This event is called before persisting to store.
		/// </summary>
		/// <param name="item"></param>
		protected internal void OnValidate(BusinessObjectEventArgs item)
		{
			if (this.Validate != null)
				this.Validate(this, item);
		}

		/// <summary>
		/// Persists this object to the database.
		/// </summary>
		public override void Persist()
		{
		  if (this.IsParented)
		  {
				this.OnValidate(new BusinessObjectEventArgs(this));
			  wrappedClass.Persist();
		  }
		  else
		    throw new Exception("This item is not part of a collection and cannot be persisted!");
		}

		/// <summary>
		/// Removes this object from its parent collection. It will not be deleted from the database.
		/// </summary>
		public void Remove()
		{
			try
			{
				if (this.ParentCollection == null)
				{
					lock (this)
					{
						wrappedClass.Remove();
					}
				}
				else
				{
					lock (this.ParentCollection.SubDomain)
					{
						wrappedClass.Remove();
					}
				}
			}
			catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
			catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
			catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
		}

		/// <summary>
		/// Marks this object for deletion. The next call to the Persist method will delete it from the database.
		/// </summary>
		public void Delete()
		{
			try
			{
				if (this.ParentCollection == null)
				{
					lock (this)
					{
						wrappedClass.Delete();
					}
				}
				else
				{
					lock (this.ParentCollection.SubDomain)
					{
						wrappedClass.Delete();
					}
				}
			}
			catch (System.Data.DBConcurrencyException dbcex) { throw new ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
			catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
			catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
		}

		#endregion

		#region Overrides

		/// <summary>
		/// Serves as a hash function for this particular type.
		/// </summary>
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		/// <summary>
		/// Returns a value indicating whether the current object is equal to a specified object.
		/// </summary>
		public override bool Equals(object obj)
		{
			if (obj == null) return false;
			if (obj.GetType() == this.GetType())
			{
				if (this.wrappedClass.Equals(((Order)obj).wrappedClass))
					return true;
			}
			else if(obj.GetType() == this.PrimaryKey.GetType())
			{
			  if(this.PrimaryKey.Equals(obj))
			    return true;
			}
			else if (obj.GetType() == this.PrimaryKey.OrderId.GetType())
			{
				if (this.PrimaryKey.OrderId.Equals(obj))
					return true;
			}
			return false;
		}

		#endregion

		#region IBusinessObject ParentCollection

		/// <summary>
		/// This is a reference back to the generic collection that holds this object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		IBusinessCollection IBusinessObject.ParentCollection
		{
			get { return this.ParentCollection; }
		}

		#endregion

		#region ParentCollection

		/// <summary>
		/// This is a reference back to the collection that holds this object.
		/// </summary>
		[System.ComponentModel.Browsable(false)]
		public OrderCollection ParentCollection
		{
			get { return new OrderCollection(wrappedClass.ParentCol); }
		}

		#endregion

		#region GetDefault

		/// <summary>
		/// Gets the default value of one of this object's properties.
		/// </summary>
		public object GetDefault(FieldNameConstants field)
		{
			if(field == FieldNameConstants.CustomerId)
				return "";
			if(field == FieldNameConstants.EmployeeId)
				return null;
			if(field == FieldNameConstants.Freight)
				return null;
			if(field == FieldNameConstants.OrderDate)
				return null;
			if(field == FieldNameConstants.OrderId)
				return 0;
			if(field == FieldNameConstants.RequiredDate)
				return null;
			if(field == FieldNameConstants.ShipAddress)
				return "";
			if(field == FieldNameConstants.ShipCity)
				return "";
			if(field == FieldNameConstants.ShipCountry)
				return "";
			if(field == FieldNameConstants.ShipName)
				return "";
			if(field == FieldNameConstants.ShippedDate)
				return null;
			if(field == FieldNameConstants.ShipPostalCode)
				return "";
			if(field == FieldNameConstants.ShipRegion)
				return "";
			if(field == FieldNameConstants.ShipVia)
				return null;

			return null;
		}

		object IBusinessObject.GetDefault(Enum field)
		{
			return this.GetDefault((FieldNameConstants)field);
		}

		#endregion

		#region GetValue

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public object GetValue(FieldNameConstants field)
		{
			return GetValue(field, null);
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public object GetValue(FieldNameConstants field, object defaultValue)
		{
			if(field == FieldNameConstants.ShipVia)
				return ((this.ShipVia == null) ? defaultValue : this.ShipVia);
			if(field == FieldNameConstants.ShipRegion)
				return ((this.ShipRegion == null) ? defaultValue : this.ShipRegion);
			if(field == FieldNameConstants.ShipPostalCode)
				return ((this.ShipPostalCode == null) ? defaultValue : this.ShipPostalCode);
			if(field == FieldNameConstants.ShippedDate)
				return ((this.ShippedDate == null) ? defaultValue : this.ShippedDate);
			if(field == FieldNameConstants.ShipName)
				return ((this.ShipName == null) ? defaultValue : this.ShipName);
			if(field == FieldNameConstants.ShipCountry)
				return ((this.ShipCountry == null) ? defaultValue : this.ShipCountry);
			if(field == FieldNameConstants.ShipCity)
				return ((this.ShipCity == null) ? defaultValue : this.ShipCity);
			if(field == FieldNameConstants.ShipAddress)
				return ((this.ShipAddress == null) ? defaultValue : this.ShipAddress);
			if(field == FieldNameConstants.RequiredDate)
				return ((this.RequiredDate == null) ? defaultValue : this.RequiredDate);
			if(field == FieldNameConstants.OrderId)
				return this.OrderId;
			if(field == FieldNameConstants.OrderDate)
				return ((this.OrderDate == null) ? defaultValue : this.OrderDate);
			if(field == FieldNameConstants.Freight)
				return ((this.Freight == null) ? defaultValue : this.Freight);
			if(field == FieldNameConstants.EmployeeId)
				return ((this.EmployeeId == null) ? defaultValue : this.EmployeeId);
			if(field == FieldNameConstants.CustomerId)
				return ((this.CustomerId == null) ? defaultValue : this.CustomerId);
			throw new Exception("Field '" + field.ToString() + "' not found!");
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public int GetInteger(FieldNameConstants field)
		{
			return this.GetInteger(field, int.MinValue);
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public int GetInteger(FieldNameConstants field, int defaultValue)
		{
			object o = this.GetValue(field, defaultValue);
			if (o is string)
			{
				int a;
				if (int.TryParse((string)o, out a))
					return a;
				else
					throw new InvalidCastException();
			}
			else
			{
				return (int)o;
			}
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public double GetDouble(FieldNameConstants field)
		{
			return this.GetDouble(field, double.MinValue);
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public double GetDouble(FieldNameConstants field, double defaultValue)
		{
			object o = this.GetValue(field, defaultValue);
			if (o is string)
			{
				double a;
				if (double.TryParse((string)o, out a))
					return a;
				else
					throw new InvalidCastException();
			}
			else
			{
				return (double)o;
			}
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public DateTime GetDateTime(FieldNameConstants field)
		{
			return this.GetDateTime(field, DateTime.MinValue);
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public DateTime GetDateTime(FieldNameConstants field, DateTime defaultValue)
		{
			object o = this.GetValue(field, defaultValue);
			if (o is string)
			{
				DateTime a;
				if (DateTime.TryParse((string)o, out a))
					return a;
				else
					throw new InvalidCastException();
			}
			else
			{
				return (DateTime)o;
			}
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public string GetString(FieldNameConstants field)
		{
			return this.GetString(field, "");
		}

		/// <summary>
		/// Gets the value of one of this object's properties.
		/// </summary>
		public string GetString(FieldNameConstants field, string defaultValue)
		{
			object o = this.GetValue(field, defaultValue);
			if (o is string)
			{
				return (string)o;
			}
			else
			{
				return o.ToString();
			}
		}

		#endregion

		#region SetValue

		/// <summary>
		/// Assigns a value to a field on this object.
		/// </summary>
		/// <param name="field">The field to set</param>
		/// <param name="newValue">The new value to assign to the field</param>
		public void SetValue(FieldNameConstants field, object newValue)
		{
			SetValue(field, newValue, false);
		}

		/// <summary>
		/// Assigns a value to a field on this object.
		/// </summary>
		/// <param name="field">The field to set</param>
		/// <param name="newValue">The new value to assign to the field</param>
		/// <param name="fixLength">Determines if the length should be truncated if too long. When false, an error will be raised if data is too large to be assigned to the field.</param>
		public void SetValue(FieldNameConstants field, object newValue, bool fixLength)
		{
			if (field == FieldNameConstants.ShipVia)
			{
				if (newValue == null)
				{
					this.ShipVia = null;
				}
				else
				{
					if(Widgetsphere.Core.Util.ReflectionHelper.ImplementsInterface(newValue, typeof(IWrappingClass)))
					{
						this.ShipVia = ((Shipper)newValue).ShipperId;
					} else if(newValue is IPrimaryKey)
					{
						this.ShipVia = ((ShipperPrimaryKey)newValue).ShipperId;
					} else
					if (newValue is string)
					{
						this.ShipVia = int.Parse((string)newValue);
					} else if (!(newValue is int?)) {
						this.ShipVia = int.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.ShipVia = (int?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipRegion)
			{
				if (newValue == null)
				{
					this.ShipRegion = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipRegion);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipRegion = v;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipPostalCode)
			{
				if (newValue == null)
				{
					this.ShipPostalCode = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipPostalCode);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipPostalCode = v;
				}
				return;
			}
			else if (field == FieldNameConstants.ShippedDate)
			{
				if (newValue == null)
				{
					this.ShippedDate = null;
				}
				else
				{
					if (newValue is string)
					{
						this.ShippedDate = DateTime.Parse((string)newValue);
					} else if (!(newValue is DateTime?)) {
						this.ShippedDate = DateTime.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.ShippedDate = (DateTime?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipName)
			{
				if (newValue == null)
				{
					this.ShipName = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipName);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipName = v;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipCountry)
			{
				if (newValue == null)
				{
					this.ShipCountry = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipCountry);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipCountry = v;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipCity)
			{
				if (newValue == null)
				{
					this.ShipCity = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipCity);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipCity = v;
				}
				return;
			}
			else if (field == FieldNameConstants.ShipAddress)
			{
				if (newValue == null)
				{
					this.ShipAddress = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.ShipAddress);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.ShipAddress = v;
				}
				return;
			}
			else if (field == FieldNameConstants.RequiredDate)
			{
				if (newValue == null)
				{
					this.RequiredDate = null;
				}
				else
				{
					if (newValue is string)
					{
						this.RequiredDate = DateTime.Parse((string)newValue);
					} else if (!(newValue is DateTime?)) {
						this.RequiredDate = DateTime.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.RequiredDate = (DateTime?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.OrderId)
			{
				throw new Exception("Field '" + field.ToString() + "' is a primary key and cannot be set!");
			}
			else if (field == FieldNameConstants.OrderDate)
			{
				if (newValue == null)
				{
					this.OrderDate = null;
				}
				else
				{
					if (newValue is string)
					{
						this.OrderDate = DateTime.Parse((string)newValue);
					} else if (!(newValue is DateTime?)) {
						this.OrderDate = DateTime.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.OrderDate = (DateTime?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.Freight)
			{
				if (newValue == null)
				{
					this.Freight = null;
				}
				else
				{
					if (newValue is string)
					{
						this.Freight = decimal.Parse((string)newValue);
					} else if (!(newValue is decimal?)) {
						this.Freight = decimal.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.Freight = (decimal?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.EmployeeId)
			{
				if (newValue == null)
				{
					this.EmployeeId = null;
				}
				else
				{
					if(Widgetsphere.Core.Util.ReflectionHelper.ImplementsInterface(newValue, typeof(IWrappingClass)))
					{
						this.EmployeeId = ((Employee)newValue).EmployeeId;
					} else if(newValue is IPrimaryKey)
					{
						this.EmployeeId = ((EmployeePrimaryKey)newValue).EmployeeId;
					} else
					if (newValue is string)
					{
						this.EmployeeId = int.Parse((string)newValue);
					} else if (!(newValue is int?)) {
						this.EmployeeId = int.Parse(newValue.ToString());
					}
					else if (newValue is IBusinessObject)
					{
						throw new Exception("An invalid object of type 'IBusinessObject' was passed in. Perhaps a relationship was not enforced correctly.");
					}
					else
					this.EmployeeId = (int?)newValue;
				}
				return;
			}
			else if (field == FieldNameConstants.CustomerId)
			{
				if (newValue == null)
				{
					this.CustomerId = null;
				}
				else
				{
					string v = newValue.ToString();
					if (fixLength)
					{
						int fieldLength = GetFieldLength(FieldNameConstants.CustomerId);
						if (v.Length > fieldLength) v = v.Substring(0, fieldLength);
					}
					this.CustomerId = v;
				}
				return;
			}
			throw new Exception("Field '" + field.ToString() + "' not found!");
		}

		#endregion

		#region GetFieldLength

		/// <summary>
		/// Determines the length of the specified field if it can be set.
		/// </summary>
		public int GetFieldLength(Order.FieldNameConstants field)
		{
			if(field == FieldNameConstants.ShipRegion) return 15;
			if(field == FieldNameConstants.ShipPostalCode) return 10;
			if(field == FieldNameConstants.ShipName) return 40;
			if(field == FieldNameConstants.ShipCountry) return 15;
			if(field == FieldNameConstants.ShipCity) return 15;
			if(field == FieldNameConstants.ShipAddress) return 60;
			if(field == FieldNameConstants.CustomerId) return 5;
			//Catch all for all other data types
			return -1;
		}
		#endregion

		#region Clone

		/// <summary>
		/// Create a copy of this object.
		/// </summary>
		public virtual IBusinessObject Clone()
		{
			lock (this)
			{
				if (!this.IsParented) throw new Exception("The current item must be parented.");
				Order newItem = null;
				lock (this.ParentCollection.SubDomain)
				{
					newItem = new Order(this.ParentCollection.wrappedClass.NewItem());
				}
				this.FillClone(newItem);
				return newItem;
			}
		}

		/// <summary>
		/// Create a copy of this object.
		/// <param name="orderid">The orderid field</param>
		/// </summary>
		public virtual IBusinessObject Clone(int orderid)
		{
			lock (this)
			{
				if (!this.IsParented) throw new Exception("The current item must be parented.");
				Order newItem = null;
				lock (this.ParentCollection.wrappedClass.SubDomain)
				{
				newItem = new Order(this.ParentCollection.wrappedClass.NewItem(orderid));
				}
				this.FillClone(newItem);
				return newItem;
			}
		}

		private void FillClone(Order newItem)
		{
			lock (this)
			{
				lock (newItem)
				{
					newItem.ShipVia = this.ShipVia;
					newItem.ShipRegion = this.ShipRegion;
					newItem.ShipPostalCode = this.ShipPostalCode;
					newItem.ShippedDate = this.ShippedDate;
					newItem.ShipName = this.ShipName;
					newItem.ShipCountry = this.ShipCountry;
					newItem.ShipCity = this.ShipCity;
					newItem.ShipAddress = this.ShipAddress;
					newItem.RequiredDate = this.RequiredDate;
					newItem.OrderDate = this.OrderDate;
					newItem.Freight = this.Freight;
					newItem.EmployeeId = this.EmployeeId;
					newItem.CustomerId = this.CustomerId;
				}
			}
		}

		object ICloneable.Clone()
		{
			return this.Clone();
		}

		#endregion

		#region Helper Methods

		string IBusinessObject.GetFriendlyName(Enum field)
		{
			return "";
		}

		/// <summary>
		/// Gets the maximum size of the field value.
		/// </summary>
		public static int GetMaxLength(FieldNameConstants field)
		{
			switch (field)
			{
				case FieldNameConstants.CustomerId:
					return 5;
				case FieldNameConstants.EmployeeId:
					return 0;
				case FieldNameConstants.Freight:
					return 0;
				case FieldNameConstants.OrderDate:
					return 0;
				case FieldNameConstants.OrderId:
					return 0;
				case FieldNameConstants.RequiredDate:
					return 0;
				case FieldNameConstants.ShipAddress:
					return 60;
				case FieldNameConstants.ShipCity:
					return 15;
				case FieldNameConstants.ShipCountry:
					return 15;
				case FieldNameConstants.ShipName:
					return 40;
				case FieldNameConstants.ShippedDate:
					return 0;
				case FieldNameConstants.ShipPostalCode:
					return 10;
				case FieldNameConstants.ShipRegion:
					return 15;
				case FieldNameConstants.ShipVia:
					return 0;
			}
			return 0;
		}

		int IBusinessObject.GetMaxLength(Enum field)
		{
			return GetMaxLength((FieldNameConstants)field);
		}

		string IBusinessObject.GetMask(Enum field)
		{
			return "";
		}

		/// <summary>
		/// Select a single object from this collection by its primary key.
		/// </summary>
		public static Order SelectUsingPK(int orderid)
		{
			return SelectUsingPK(orderid, "");
		}

		/// <summary>
		/// Select a single object from this collection by its primary key.
		/// </summary>
		public static Order SelectUsingPK(int orderid, string modifier)
		{
			OrderCollection order = OrderCollection.SelectUsingPK(orderid, modifier);
			if (order.Count > 1) throw new Exception("Order primary key returned more than one value.");
			else if (order.Count == 0) return null;
			else return order[0];
		}

		#endregion

		#region IBusinessObject Members

		IPrimaryKey IBusinessObject.PrimaryKey
		{
			get { return this.PrimaryKey; }
		}

		object IBusinessObject.GetValue(Enum field)
		{
			return this.GetValue((FieldNameConstants)field);
		}

		object IBusinessObject.GetValue(Enum field, object defaultValue)
		{
			return this.GetValue((FieldNameConstants)field, defaultValue);
		}

		double IBusinessObject.GetDouble(Enum field)
		{
			return this.GetDouble((FieldNameConstants)field);
		}

		double IBusinessObject.GetDouble(Enum field, double defaultValue)
		{
			return this.GetDouble((FieldNameConstants)field, defaultValue);
		}

		DateTime IBusinessObject.GetDateTime(Enum field)
		{
			return this.GetDateTime((FieldNameConstants)field);
		}

		DateTime IBusinessObject.GetDateTime(Enum field, DateTime defaultValue)
		{
			return this.GetDateTime((FieldNameConstants)field, defaultValue);
		}

		int IBusinessObject.GetInteger(Enum field)
		{
			return this.GetInteger((FieldNameConstants)field);
		}

		int IBusinessObject.GetInteger(Enum field, int defaultValue)
		{
			return this.GetInteger((FieldNameConstants)field, defaultValue);
		}

		string IBusinessObject.GetString(Enum field)
		{
			return this.GetString((FieldNameConstants)field);
		}

		string IBusinessObject.GetString(Enum field, string defaultValue)
		{
			return this.GetString((FieldNameConstants)field, defaultValue);
		}

		void IPersistableBusinessObject.SetValue(Enum field, object newValue)
		{
			this.SetValue((FieldNameConstants)field, newValue);
		}

		Enum IBusinessObject.Container
		{
			get { return this.Container; }
		}

		/// <summary>
		/// Determines if all of the fields for the specified object exactly matches the current object.
		/// </summary>
		/// <param name="item">The object to compare</param>
		public override bool IsEquivalent(IBusinessObject item)
		{
			if (item == null) return false;
			if (!(item is Order)) return false;
			Order o = item as Order;
			return (
				o.ShipVia == this.ShipVia &&
				o.ShipRegion == this.ShipRegion &&
				o.ShipPostalCode == this.ShipPostalCode &&
				o.ShippedDate == this.ShippedDate &&
				o.ShipName == this.ShipName &&
				o.ShipCountry == this.ShipCountry &&
				o.ShipCity == this.ShipCity &&
				o.ShipAddress == this.ShipAddress &&
				o.RequiredDate == this.RequiredDate &&
				o.OrderId == this.OrderId &&
				o.OrderDate == this.OrderDate &&
				o.Freight == this.Freight &&
				o.EmployeeId == this.EmployeeId &&
				o.CustomerId == this.CustomerId
				);
		}

		#endregion

		#region IAuditable Members

		string IAuditable.CreatedBy
		{
			get { return this.CreatedBy; }
		}

		DateTime? IAuditable.CreatedDate
		{
			get { return this.CreatedDate; }
		}

		bool IAuditable.IsCreateAuditImplemented
		{
			get { return true; }
		}

		bool IAuditable.IsModifyAuditImplemented
		{
			get { return true; }
		}

		bool IAuditable.IsTimestampAuditImplemented
		{
			get { return true; }
		}

		string IAuditable.ModifiedBy
		{
			get { return this.ModifiedBy; }
		}

		DateTime? IAuditable.ModifiedDate
		{
			get { return this.ModifiedDate; }
		}

		byte[] IAuditable.TimeStamp
		{
			get { return this.TimeStamp; }
		}

		#endregion

	}

}
